#pragma once

#include <QtWidgets/QWidget>
#include "ui_OpenGLDemo.h"
#include "GLWidget.h"
#include "QGLWidget.h"
#include <QMatrix4x4>

#define ENABLE_ROAMING		1

class Model;
class Shader;
class Camera;
class Texture2D;
class OpenGLDemo : public OGLWidget
{
	Q_OBJECT

public:
	OpenGLDemo(QWidget *parent = Q_NULLPTR);

	void initializeGL();
	void resizeGL(int w, int h);
	void paintGL();

	void closeEvent(QCloseEvent *event);

protected:

	void keyPressEvent(QKeyEvent *event);

	void keyReleaseEvent(QKeyEvent *event);

	void mousePressEvent(QMouseEvent *event);

	void mouseMoveEvent(QMouseEvent *event);

	void wheelEvent(QWheelEvent *event);

private slots:
	void Tick();
private:
	Ui::OpenGLDemoClass ui;

	GLuint pbo;
	Texture2D* readTex;

	Model* quadModel = nullptr, *sphereModel = nullptr, *teapotModel = nullptr;
	Shader* shader = nullptr, *shader2, *shader3, *smallScreenShader = nullptr;
	Texture2D* texture = nullptr, *texture2;

	bool isExit = false;
	Camera* camera = nullptr;
	QMatrix4x4 projMat;

#if ENABLE_ROAMING
	QPoint lastPoint;
	bool isPressW = false, isPressS = false, isPressA = false, isPressD = false, isPressQ = false, isPressE = false;
	float speed = 1.0f;
	float rotateSpeed = 1.0f;
#endif
};
